; Amiga Boot Selector
; -------------------
;
; Date: 2021-11-28
; Author: Henrik Noerfjand Stengaard
;
; User package for HstWB Installer to automate installation of Amiga Boot Selector by Michael GiBS.
;
; References:
; http://ohmygibs.free.fr/ohmygibs/Amiga_Boot_Selector.html
; https://sites.google.com/one-n.co.uk/amiga-guides/amiga-boot-selector-abs
; https://www.amigafrance.com/tutoriel-install-and-setup-amiga-boot-selector-2/


; paths
set startupsequence "`execute INSTALLDIR:S/CombinePath "$INSTALLDIR" "S/Startup-Sequence"`"

; write install status
echo "ABS..."

; copy abs to install dir
Copy >NIL: "USERPACKAGEDIR:abs/#?" "$INSTALLDIR" ALL CLONE

; add boot selector startup to startup sequence, if not present
Search >NIL: "$startupsequence" "BindDrivers" quiet
IF $RC EQ 0 VAL
  ; add boot selector startup to startup sequence before "BindDrivers", if not present
  Search >NIL: "$startupsequence" "S:BootSelector-Startup" quiet
  IF NOT $RC EQ 0 VAL
    rep "$startupsequence" "BindDrivers" "IF EXISTS S:BootSelector-Startup*N  Execute S:BootSelector-Startup*NEndIf*NBindDrivers"
  ENDIF
ELSE
  echo "*e[1mError: Unable to add boot selector startup,*N'BindDrivers'*Nnot found in startup sequence '$startupsequence'.*NBoot selector can't be installed without this!*e[0m"
  ask "Press ENTER to continue"
ENDIF
